package com.woniuxy.hrm.controller;

import com.woniuxy.hrm.entity.Good;
import com.woniuxy.hrm.entity.Order;
import com.woniuxy.hrm.service.GoodService;
import com.woniuxy.hrm.util.ResponseData;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@AllArgsConstructor
@RequestMapping("/good")
public class GoodController {
    private GoodService goodService;
    @GetMapping("/queryAllGood")
    public ResponseData<?> queryAllGood() {
        return goodService.queryAllGood();
    }
    @PostMapping("addOrder")
    @ResponseBody
    public ResponseData<?> addGood(@RequestBody List<Good> goodList) {
        ;
        return ResponseData.ok(goodService.addOrder(goodList));
    }
    @GetMapping("/queryAllOrder")
    public ResponseData<?> queryAllOrder() {
        return goodService.queryAllOrder();
    }
    @PostMapping("/goodPayOrder")
    @ResponseBody
    public ResponseData<?> goodPayOrder(@RequestBody Order order) {
        return goodService.goodPayOrder(order);
    }
    @PostMapping("/handleCancel")
    public ResponseData<?> handleCancel(@RequestBody Order order) {
        return goodService.handleCancel(order);
    }
    @PostMapping("/getOrderItemByOrderId")
    @ResponseBody
    public ResponseData<?> getOrderItemByOrderId(@RequestBody Order order) {
        return goodService.getOrderItemByOrderId(order);
    }
}
